﻿
using Xacml.Core;
using System;
using System.Xml;

namespace Xacml.Core.Policy
{
  public class TargetElement : TargetElementReadWrite
  {
    public override ResourcesElementReadWrite Resources
    {
      get
      {
        if (base.Resources != null)
          return (ResourcesElementReadWrite) new ResourcesElement(base.Resources.IsAny, base.Resources.ItemsList, base.Resources.SchemaVersion);
        return (ResourcesElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override SubjectsElementReadWrite Subjects
    {
      get
      {
        if (base.Subjects != null)
          return (SubjectsElementReadWrite) new SubjectsElement(base.Subjects.IsAny, base.Subjects.ItemsList, base.Subjects.SchemaVersion);
        return (SubjectsElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override ActionsElementReadWrite Actions
    {
      get
      {
        if (base.Actions != null)
          return (ActionsElementReadWrite) new ActionsElement(base.Actions.IsAny, base.Actions.ItemsList, base.Actions.SchemaVersion);
        return (ActionsElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override EnvironmentsElementReadWrite Environments
    {
      get
      {
        if (base.Environments != null)
          return (EnvironmentsElementReadWrite) new EnvironmentsElement(base.Environments.IsAny, base.Environments.ItemsList, base.Environments.SchemaVersion);
        return (EnvironmentsElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public TargetElement(ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion)
      : base(resources, subjects, actions, environments, schemaVersion)
    {
    }

    public TargetElement(XmlReader reader, XacmlVersion schemaVersion)
      : base(reader, schemaVersion)
    {
    }
  }
}
